package com.sun.weekend.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.sun.weekend.R;
import com.sun.weekend.util.ViewHolder;
import com.sun.weekend.view.VideoPlayer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */

public class CommentAdapter extends BaseAdapter{

    private List items = new ArrayList();
    private Context mContext;
    private LayoutInflater mInflater;
    public CommentAdapter(Context mContext) {
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return items.size();
    }

    public CommentAdapter append(List list) {
        items.addAll(list);
        notifyDataSetChanged();
        return this;
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.task_comment_item,null);
        }
        VideoPlayer videoPlayer = (VideoPlayer) ViewHolder.getView(convertView,R.id.player);
        videoPlayer.setTag(position);
        return convertView;
    }
}
